package com.guoyan.blockchain.common.util;

import com.alibaba.fastjson.JSON;
import com.guoyan.blockchain.component.model.Model;
import org.apache.commons.codec.digest.DigestUtils;

/**
 * @author yeym
 */
public class EncodeUtil {
    public static String sha256(Model model) {
        String s = JSON.toJSONString(model);
        double nonce = Math.random();
        return DigestUtils.md5Hex(s+nonce);
    }
    public static String sha256(String model) {
        double nonce = Math.random();
        return DigestUtils.md5Hex(model+nonce);
    }

    public static void main(String[] args) {
        System.out.println(EncodeUtil.class.getName());
    }
}
